

/**************************************TRIM IN JAVASCRIPT STARTS FROM HERE************************************************/
// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}


function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

/************************************************TRIM IN JAVASCRIPT ENDS HERE*******************************************/

function contact_chk()
	{

	var EmailVALIdation=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var NameVAlidation=/[0-9\*\=\_\>\<\:\@\&\%\?\$\-\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\+\#\\]/;
	var PhonEVAlidation=/[a-zA-Z\*\=\_\>\<\:\@\&\%\?\$\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\\]/;
	var messageVAlidation=/[?\>\<\\]/;

		if(document.getElementById("UsernamE") != null)
	
		{
	
			if(document.getElementById("UsernamE").value != '')
	
			{
	
				//alert(document.getElementById("UsernamE").value)
	
				//alert(document.getElementById("UsernamE").value.search(NameVAlidation))
	
				if(document.getElementById("UsernamE").value.search(NameVAlidation) >= 0 )
	
				{
	
					document.getElementById("UserNameError").innerHTML="<br>Your Name Should Be Only Charecters.";
	
					document.getElementById("UserNameError").style.display='';
	
					document.getElementById("UsernamE").ClassName="RedClass";
	
					document.getElementById("UsernamE").focus();
	
					return false;
	
				}
	
				var str =Trim(document.getElementById("UsernamE").value);
	
				if( str=='')
	
				{
	
					document.getElementById("UserNameError").innerHTML="<br>Please Dont Give Space In Name Field.";
	
					document.getElementById("UserNameError").style.display='';
	
					document.getElementById("UsernamE").ClassName="RedClass";
	
					document.getElementById("UsernamE").value="";
	
					document.getElementById("UsernamE").focus();
	
					return false;
	
				}
	
				else
	
				{
	
					document.getElementById("UserNameError").innerHTML="";
	
					document.getElementById("UserNameError").style.display='none';
	
					document.getElementById("UsernamE").ClassName="NormalClass";		
	
				}
	
			}
	
			else
	
			{
	
				if(document.getElementById("UserNameError") != null)
	
				{
	
					document.getElementById("UserNameError").innerHTML="<br>Please Type Your Name.";
	
					document.getElementById("UserNameError").style.display='';
	
					document.getElementById("UsernamE").ClassName="RedClass";
	
					document.getElementById("UsernamE").focus();
	
					return false;
	
				}
	
			}
	
		}
		
		
		
		if(document.getElementById("EmaiL") != null)
	
		{
	

			if(document.getElementById("EmaiL").value != '')
	
			{
	
				if(!EmailVALIdation.test(document.getElementById("EmaiL").value))
	
				{
	
					document.getElementById("EmaiLError").innerHTML="<br>Invalid Email Address.";
	
					document.getElementById("EmaiLError").style.display='';
	
					document.getElementById("EmaiL").ClassName="RedClass";
	
					document.getElementById("EmaiL").focus();
	
					return false;
	
				}
	
				var str =Trim(document.getElementById("EmaiL").value);
	
				if( str=='')
	
				{
	
					document.getElementById("EmaiLError").innerHTML="<br>Please Dont Give Space In Email Field.";
	
					document.getElementById("EmaiLError").style.display='';
	
					document.getElementById("EmaiL").ClassName="RedClass";
	
					document.getElementById("EmaiL").value="";
	
					document.getElementById("EmaiL").focus();
	
					return false;
	
				}
	
				else
	
				{
	
					document.getElementById("EmaiLError").innerHTML="";
	
					document.getElementById("EmaiLError").style.display='none';
	
					document.getElementById("EmaiL").ClassName="NormalClass";		
	
				}
	
			}
	
			else
	
			{
	
				if(document.getElementById("EmaiLError") != null)
	
				{
	
			
	
					document.getElementById("EmaiLError").innerHTML="<br>Please Type Your Email.";
	
					document.getElementById("EmaiLError").style.display='';
	
					document.getElementById("EmaiL").ClassName="RedClass";
	
					document.getElementById("EmaiL").focus();
	
					return false;
	
				}
	
			}
	
		}

		if(document.getElementById("phno") != null)
		{

			if(document.getElementById("phno").value != '')
			{	//alert(document.getElementById("phno").value);
				if(document.getElementById("phno").value.search(PhonEVAlidation) >= 0)
				{	
					document.getElementById("phnoError").innerHTML="<br>Invalid  Phone Number.";
					document.getElementById("phnoError").style.display='';
					document.getElementById("phno").ClassName="RedClass";
					document.getElementById("phno").focus();
					return false;
				}
				var str =Trim(document.getElementById("phno").value);
				if( str=='')
				{
					document.getElementById("phnoError").innerHTML="<br>Please Dont Give Space In  Phone Field.";
					document.getElementById("phnoError").style.display='';
					document.getElementById("phno").ClassName="RedClass";
					document.getElementById("phno").value="";
					document.getElementById("phno").focus();
					return false;
				}
				else
				{
					document.getElementById("phnoError").innerHTML="";
					document.getElementById("phnoError").style.display='none';
					document.getElementById("phno").ClassName="NormalClass";		
				}

			}
			else
			{

				if(document.getElementById("phnoError") != null)
				{
					document.getElementById("phnoError").innerHTML="<br>Please Type Your  Phone Number.";
					document.getElementById("phnoError").style.display='';
					document.getElementById("phno").ClassName="RedClass";
					document.getElementById("phno").focus();
					return false;
				}
			}
		}

	if(document.getElementById("address") != null)
	
		{
	
			if(document.getElementById("address").value != '')
	
			{
	
				//alert(document.getElementById("address").value)
	
				//alert(document.getElementById("address").value.search(NameVAlidation))
	
	
				var str =Trim(document.getElementById("address").value);
	
				if( str=='')
	
				{
	
					document.getElementById("AddrError").innerHTML="<br>Please Dont Give Space In Address Field.";
	
					document.getElementById("AddrError").style.display='';
	
					document.getElementById("address").ClassName="RedClass";
	
					document.getElementById("address").value="";
	
					document.getElementById("address").focus();
	
					return false;
	
				}
	
				else
	
				{
	
					document.getElementById("AddrError").innerHTML="";
	
					document.getElementById("AddrError").style.display='none';
	
					document.getElementById("address").ClassName="NormalClass";		
	
				}
	
			}
	
			else
	
			{
	
				if(document.getElementById("AddrError") != null)
	
				{
	
					document.getElementById("AddrError").innerHTML="<br>Please Type Your Address.";
	
					document.getElementById("AddrError").style.display='';
	
					document.getElementById("address").ClassName="RedClass";
	
					document.getElementById("address").focus();
	
					return false;
	
				}
	
			}
	
		}


	if(document.getElementById("Country") != null)
	
		{
	
			if(document.getElementById("Country").value != '')
	
			{
	
				//alert(document.getElementById("Country").value)	
				//alert(document.getElementById("Country").value.search(NameVAlidation))

				if(document.getElementById("Country").value.search(NameVAlidation) >= 0 )
					{
						document.getElementById("CountryError").innerHTML="<br>Your Country Name Should Be Only Charecters.";
						document.getElementById("CountryError").style.display='';
						document.getElementById("Country").ClassName="RedClass";
						document.getElementById("Country").focus();
						return false;
					}
	
				var str =Trim(document.getElementById("Country").value);
	
				if( str=='')
	
				{
	
					document.getElementById("CountryError").innerHTML="<br>Please Dont Give Space In Country Field.";
	
					document.getElementById("CountryError").style.display='';
	
					document.getElementById("Country").ClassName="RedClass";
	
					document.getElementById("Country").value="";
	
					document.getElementById("Country").focus();
	
					return false;
	
				}
	
				else
	
				{
	
					document.getElementById("CountryError").innerHTML="";
	
					document.getElementById("CountryError").style.display='none';
	
					document.getElementById("Country").ClassName="NormalClass";		
	
				}
	
			}
	
			else
	
			{
	
				if(document.getElementById("CountryError") != null)
	
				{
	
					document.getElementById("CountryError").innerHTML="<br>Please Type Your Country Name.";
	
					document.getElementById("CountryError").style.display='';
	
					document.getElementById("Country").ClassName="RedClass";
	
					document.getElementById("Country").focus();
	
					return false;
	
				}
	
			}
	
		}


	if(document.getElementById("State") != null)
	
		{
	
			if(document.getElementById("State").value != '')
	
			{
	
				//alert(document.getElementById("State").value)	
				//alert(document.getElementById("State").value.search(NameVAlidation))

				if(document.getElementById("State").value.search(NameVAlidation) >= 0 )
					{
						document.getElementById("StateError").innerHTML="<br>Your State Name Should Be Only Charecters.";
						document.getElementById("StateError").style.display='';
						document.getElementById("State").ClassName="RedClass";
						document.getElementById("State").focus();
						return false;
					}
	
				var str =Trim(document.getElementById("State").value);
	
				if( str=='')
	
				{
	
					document.getElementById("StateError").innerHTML="<br>Please Dont Give Space In State Field.";
	
					document.getElementById("StateError").style.display='';
	
					document.getElementById("State").ClassName="RedClass";
	
					document.getElementById("State").value="";
	
					document.getElementById("State").focus();
	
					return false;
	
				}
	
				else
	
				{
	
					document.getElementById("StateError").innerHTML="";
	
					document.getElementById("StateError").style.display='none';
	
					document.getElementById("State").ClassName="NormalClass";		
	
				}
	
			}
	
			else
	
			{
	
				if(document.getElementById("StateError") != null)
	
				{
	
					document.getElementById("StateError").innerHTML="<br>Please Type Your State Name.";
	
					document.getElementById("StateError").style.display='';
	
					document.getElementById("State").ClassName="RedClass";
	
					document.getElementById("State").focus();
	
					return false;
	
				}
	
			}
	
		}
		


	if(document.getElementById("City") != null)
	
		{
	
			if(document.getElementById("City").value != '')
	
			{
	
				//alert(document.getElementById("City").value)	
				//alert(document.getElementById("City").value.search(NameVAlidation))

				if(document.getElementById("City").value.search(NameVAlidation) >= 0 )
					{
						document.getElementById("CityError").innerHTML="<br>Your City Name Should Be Only Charecters.";
						document.getElementById("CityError").style.display='';
						document.getElementById("City").ClassName="RedClass";
						document.getElementById("City").focus();
						return false;
					}
	
				var str =Trim(document.getElementById("City").value);
	
				if( str=='')
	
				{
	
					document.getElementById("CityError").innerHTML="<br>Please Dont Give Space In City Field.";
	
					document.getElementById("CityError").style.display='';
	
					document.getElementById("City").ClassName="RedClass";
	
					document.getElementById("City").value="";
	
					document.getElementById("City").focus();
	
					return false;
	
				}
	
				else
	
				{
	
					document.getElementById("CityError").innerHTML="";
	
					document.getElementById("CityError").style.display='none';
	
					document.getElementById("City").ClassName="NormalClass";		
	
				}
	
			}
	
			else
	
			{
	
				if(document.getElementById("CityError") != null)
	
				{
	
					document.getElementById("CityError").innerHTML="<br>Please Type Your City Name.";
	
					document.getElementById("CityError").style.display='';
	
					document.getElementById("City").ClassName="RedClass";
	
					document.getElementById("City").focus();
	
					return false;
	
				}
	
			}
	
		}

		
		
			if( document.getElementById("MeessagE").value =='')
	
			{
				document.getElementById("MessagEError").innerHTML="<br>Please Give The Message .";
	
				document.getElementById("MessagEError").style.display='';
	
				document.getElementById("MeessagE").ClassName="RedClass";
	
				document.getElementById("MeessagE").value="";
	
				document.getElementById("MeessagE").focus();
	
				return false;
	
			}
	

	 return true;
	}
